package com.ktjy.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class RegisterController {
    private static final Logger LOGGER = LoggerFactory.getLogger(RegisterController.class);

    @RequestMapping("/register")
    public String register(HttpServletRequest request) {
        LOGGER.info("Spring MVC框架搭建成功,当前请求路径:{}", request.getRequestURI());
        return "register";
    }

    @RequestMapping("/doregister")
    public String doregister(Model model, @RequestParam(value = "username") String username, @RequestParam(value = "password") String password, HttpServletRequest request) {
        model.addAttribute("username", username);
        model.addAttribute("password", password);
        LOGGER.info("Spring MVC框架搭建成功,当前请求路径:{}", request.getRequestURI());
        return "/success";
    }
}
